package com.example.duomeitijuhe.service;

import android.os.AsyncTask;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

/**
 * Created by lx on 2014/10/16.
 */
public class httpSupport {

        private  String request ;

        public  httpSupport( String request ){
            this.request = request ;
        }

        public  String sendRequest(){
            HttpURLConnection urlConnection = null ;

            StringBuffer jsonString = new StringBuffer() ;

            try {

                URL url = new URL(request) ;
                urlConnection = (HttpURLConnection) url.openConnection();
                urlConnection.connect();

                InputStreamReader is = new InputStreamReader( urlConnection.getInputStream() , "UTF-8") ;
                BufferedReader bufferedReader = new BufferedReader(is) ;

                String line = bufferedReader.readLine() ;

                while (line!=null){
                    jsonString.append(line).append("/r/n") ;
                    line = bufferedReader.readLine() ;
                }

                is.close();

            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }

            return jsonString.toString() ;

        }


}
